package swipe.painter;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.RectF;

/* compiled from: MaskPainter.kt */
public final class MaskPainter extends Painter {
    private static final PointFConverter n = new PointFConverter() {
        @Override
        public float convert(PointF pointF) {
            return pointF.x;
        }
    };
    private static final PointFConverter o = new PointFConverter() {
        @Override
        public float convert(PointF pointF) {
            return pointF.y;
        }
    };
    private final Paint paint;
    private final PointF d = new PointF();
    private final PointF e = new PointF();
    private final PointF f = new PointF();
    private final PointF g = new PointF();
    private final PointF h = new PointF();
    private final Path i = new Path();
    private final PointF j = new PointF();
    private final RectF k = new RectF();
    private float l;
    private float m = 0.5f;
    private boolean isRight;

    /* compiled from: MaskPainter.kt */
    public static final class a {
        private a() {
        }
    }

    public MaskPainter() {
        this(false);
    }

    public MaskPainter(boolean isRight) {
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(-16777216);
        paint.setAlpha(0);
        paint.setStyle(Style.FILL);
        this.paint = paint;
        this.isRight = isRight;
    }

    public final RectF a() {
        return this.k;
    }

    public final void a(float f) {
        this.l = f;
    }

    public final void b(float f) {
        this.m = f;
    }

    public final PointF b() {
        PointF pointF = this.j;
        pointF.x = this.k.centerX();
        pointF.y = this.k.centerY() + (this.m * ((float) d()));
        return pointF;
    }

    public final void reset() {
        e();
        this.paint.setAlpha((int) (255f * this.l * 0.8f));
    }

    public void a(int i, int i2) {
        super.a(i, i2);
        e();
    }

    public void a(Canvas canvas) {
        float d = this.m * ((float) d());
        int save = canvas.save();
        if (isRight) {
            canvas.scale(-1, 1, canvas.getWidth() / 2, canvas.getHeight() / 2);
        }
        canvas.translate(0, d);
        try {
            canvas.drawPath(this.i, this.paint);
        } finally {
            canvas.restoreToCount(save);
        }
    }

    private final void e() {
        float d = (0.3f * ((float) d())) / ((float) 2);
        this.d.set(0, -d);
        this.e.set(0, -0.19999999f * d);
        this.f.set((0.18f * this.l) * ((float) c()), 0);
        this.g.set(0, 0.19999999f * d);
        this.h.set(0, d);
        f();
    }

    private final void f() {
        Path path = this.i;
        path.reset();
        path.moveTo(this.d.x, this.d.y);
        for (int i = 1; i <= 20; i++) {
            float f = ((float) i) * 0.05f;
            path.lineTo(a(f, n), a(f, o));
        }
        path.close();
        RectF rectF = this.k;
        rectF.left = a((float) 0, n);
        rectF.top = a((float) 0, o);
        rectF.right = a(0.5f, n);
        rectF.bottom = a(1.0f, o);
    }

    private final float a(float f, PointFConverter converter) {
        return (converter.convert(this.h) * ((float) Math.pow((double) f,
                (double) 4))) + ((((((float) Math.pow((double) (((float) 1) - f),
                (double) 4)) * ((Number) converter.convert(this.d)).floatValue()) + (((((Number) converter.convert(this.e)).floatValue() * ((float) 4)) * f) * ((float) Math.pow((double) (((float) 1) - f), (double) 3)))) + (((((Number) converter.convert(this.f)).floatValue() * ((float) 6)) * ((float) Math.pow((double) f, (double) 2))) * ((float) Math.pow((double) (((float) 1) - f), (double) 2)))) + (((((Number) converter.convert(this.g)).floatValue() * ((float) 4)) * ((float) Math.pow((double) f, (double) 3))) * (((float) 1) - f)));
    }

    private interface PointFConverter {
        float convert(PointF pointF);
    }

}
